package org.lzy.shop.viewmodel.repository.lmpl

import org.lzy.shop.datas.SubmitOrderNewRequest
import org.lzy.shop.network.KtorApiService
import org.lzy.shop.response.ConifimOrderResponse
import org.lzy.shop.response.SubmitOrderSuccessResponse
import org.lzy.shop.viewmodel.repository.BaseRepository
import org.lzy.shop.viewmodel.repository.SubmitOrderRepository

class SubmitOrderRepositoryImpl : BaseRepository(), SubmitOrderRepository {

    override suspend fun confirmOrder(): ConifimOrderResponse? {
        return safeApiCall {
            val response = KtorApiService.confirmOrder()
            handleResponse(response)
        }
    }

    override suspend fun createOrder(request: SubmitOrderNewRequest): SubmitOrderSuccessResponse? {
        return safeApiCall {
            val response = KtorApiService.createOrder(request)
            handleResponse(response)
        }
    }
}